package com.forgweb.controller;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.forgweb.service.ForgService;


@Controller
@RequestMapping("/test")
public class ForgController {
	
	Logger logger = Logger.getLogger(ForgController.class);
	
	@Autowired
	ForgService forgService;
	
	@RequestMapping("/{name}")
	@ResponseBody
	public String sayhello(@PathVariable("name") String name){
		
		logger.info("kan>PathVariable,name= " + name);
		
		return forgService.sayHello(name);
	}
	
	@RequestMapping("/velocity")
	public String sayhelloVelocity(@RequestParam("name")String name,ModelMap model){
		
		model.addAttribute("name",name);
		
		return "velocity_index";
	}
	
	@RequestMapping("/jsp")
	public String sayhelloJsp(@RequestParam("name")String name,ModelMap model){
		
		model.addAttribute("name",name);
		
		return "jsp_index";
	}
}
